var arr
/* arr=[5,6,3,4,4,5] */
arr=[5,6,3,4,454,58,4,5,45,5]


for (let i = 0,len=arr.length; i < len-1; i++) {
    let min=arr[i]
    let minIndex=-1
    for (let j = i; j <len-1; j++) {
        if(arr[j]<arr[j+1]){
            if(arr[j]<min){
                min=arr[j]
                minIndex=j
            }
        }
        else{
            if(arr[j+1]<min){
                min=arr[j+1]
                minIndex=j+1
            }
        }
        
    }
    for (let k = minIndex; k >=i+1; k--) {
        arr[k]=arr[k-1]
        
    }
    arr[i]=min
    console.log(arr);
}
